﻿using System;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Components.Security;
using ASPNETVN.PORTAL.Components.UI;

namespace ASPNETVN.PORTAL.Modules.SUPPORT
{
    public enum ModulePages
    {
        Topic,
        Message
    }

    public enum TopicStatus
    {
        NewTopic = 0,
        NewTopicHasMessage = 1,
        OldTopic = 2,
        OldTopicHasMessage = 3
    }


    public partial class Main : PortalModuleControl
    {        
        private void LoadModulePage()
        {
            const string basePath = "~/Modules/ASPNETVN.PORTAL.Modules.SUPPORT/";
            const string pageQuery = "page";
            string pageName = Request.QueryString[pageQuery];

            ModulePages page;
            if (pageName == null)
            {
                page = ModulePages.Topic;
            }
            else
            {
                page = (ModulePages)Enum.Parse(typeof(ModulePages), Request.QueryString[pageQuery], true);
            }

            string src = string.Format("{0}Controls/{1}.ascx", basePath, page);
            ModulePage ctl = (ModulePage)this.LoadControl(src);
            ctl.ParentControl = this;
            this.divContent.Controls.Add(ctl);
        }
        
        //-----------------------------------------------------------------------------------------
        
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            hlSendQuestion.NavigateUrl = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "AddEditTopic");
            hlMonitor.NavigateUrl = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "Monitor");
            hlCategory.NavigateUrl = HttpUrlBuilder.BuildShareUrl(this.ModuleID, 0, "CategoryManager");
        }
        
        //-----------------------------------------------------------------------------------------
        
        protected void Page_Load(object sender, EventArgs e)
        {
            this.LoadModulePage();
       }
    }
}